<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>借阅记录</title>
    <link href="../css/table.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="../js/table.js"></script>
</head>
<script type="text/javascript">

</script>
<body>
<h2>借阅记录列表</h2>

请输入读者编号查询:
<form action="${basePath}record/recordByReader" method="post">
    <input type="text" name="readerId"/>
    <input type="submit" value="查询"/>
</form>

请输入图书编号查询:
<form action="${basePath}record/recordByBook" method="post">
    <input type="text" name="serialNumber"/>
    <input type="submit" value="查询"/>
</form>

<form action="${basePath}record/getAllRecord" method="post">
    <input type="submit" value="所有记录"/>
</form>
<table>
    <thead>
    <tr>
        <th>读者编号</th>
        <th>读者姓名</th>
        <th>图书编号</th>
        <th>图书名</th>
        <th>借阅时间</th>
        <th>应归还时间</th>
        <th>是否归还</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="record" items="${recordList}">
        <input type="hidden" id="recordId" name="recordId"
               value="${record.id}"/>
        <input type="hidden" id="number" name="number" value="${record.book.amount}"/>
        <input type="hidden" id="bookId" name="bookId" value="${record.book.id}"/>
        <tr>
            <td>${record.reader.id}</td>
            <td>${record.reader.name}</td>
            <td>${record.book.id}</td>
            <td>${record.book.name}</td>
            <td>${record.createTime1}</td>
            <td>${record.returnTime}</td>
            <td><c:choose>
                <c:when test="${record.isReturn ==1}">
                    <input type="checkBox" disabled="disabled"/>
                </c:when>
                <c:otherwise>
                    <input type="checkBox" checked="checked" disabled="disabled"/>
                </c:otherwise>
            </c:choose></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
<script type="text/javascript">
    function returnBook() {
        confirm('确认归还吗？');
        var recordId1 = document.getElementById("recordId").value;
        var number1 = document.getElementById("number").value;
        var bookId1 = document.getElementById("bookId").value;
        document.operationForm.action = "${basePath}/record/Record_returnBook.action?recordId="
        ${recordId}"&number=number1&bookId=bookId1";
        document.operationForm.submit();
    }
</script>
</html>
